const BASEURL = "https://app.yinuoxinnengyuan.cn/index.php"

export default (method, path, data = {}, noMemberId = false) => {
	return new Promise((resolve, reject) => {
		const user_id = uni.getStorageSync("id")||''
		if (user_id) {
			data.user_id = user_id
			if (!noMemberId) {
				data.member_id = user_id
			}
		}
		uni.request({
			url: BASEURL + path,
			data,
			method,
			header: {
				'Content-Type': 'application/x-www-form-urlencoded',
			},
			success: (res) => {
				resolve(res.data)
			},
			fail(e) {
				uni.showModal({
					title: "请求失败",
					content: e
				})
				reject(e)
			}
		})
	})

}